#include "mainwindow.h"

#include <QApplication>

class A{
public:
    virtual ~A(){}
    virtual void foo(){
        qDebug()<<"A is a foo()"<<endl;
        bar();
    }
    virtual void bar(){
        qDebug()<<"A is a bar"<<endl;
    }
};

class B:public A{
public:
     void foo(){
        qDebug()<<"B is a foo()"<<endl;
        bar();
    }
     void bar(){
        qDebug()<<"B is a bar"<<endl;
    }
};

int main(int argc, char *argv[])
{
    B obj;
    A* aptr = &obj;
    aptr->foo();
    qDebug()<<"------------"<<endl;
    A aobj = *aptr;
    aobj.foo();
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}
